package cn.kz.hrm.fallbackmethods;

import cn.kz.hrm.feignclients.CourseClientsFeign;
import cn.kz.hrm.util.AjaxResult;
import feign.hystrix.FallbackFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;

@Component
public class CourseClientsFeignFallbackFactory implements FallbackFactory<CourseClientsFeign> {

    private Logger logger = LoggerFactory.getLogger(CourseClientsFeignFallbackFactory.class);

    @Override
    public CourseClientsFeign create(Throwable throwable) {
        return new CourseClientsFeign() {
            @Override
            public AjaxResult getCourseById(Long id) {
                throwable.printStackTrace();
                logger.error("添加到购物车失败！");
                return AjaxResult.me().setSuccess(false).setMessage("添加到购物车失败");
            }
        };
    }
}
